home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT46.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.5 KB  |  68 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 46                         
  5.                                                                               
  6.  This example shows the use of the whline command to draw fast horizontal    
  7.  lines. It will also use the timing commands to make the demo run for as      
  8.  close to 5 seconds as possible (regardless of CPU speed).                   
  9.                                                                               
  10.  *** PROJECT ***                                                             
  11.  This program requires the WGT5_WC.LIB file to be linked.                    
  12.                                                                               
  13.  *** DATA FILES ***                                                          
  14.  None.                                                                       
  15.                                                            WATCOM C++ VERSION 
  16. ==============================================================================
  17. */
  18.  
  19. #include <dos.h>
  20. #include <stdlib.h>
  21. #include <wgt5.h>
  22.  
  23. int loopctr;
  24.  
  25. void timerctr (void)
  26. {
  27.   loopctr++;
  28. }
  29.  
  30.  
  31. void main (void)
  32. {
  33.   short row;
  34.   short oldmode;
  35.  
  36.   if ( !vgadetected () )
  37.   {
  38.     printf ("Error - VGA card required for any WGT program.\n");
  39.     exit (0);
  40.   }
  41.  
  42.   printf ("WGT Example #46\n\n");
  43.   printf ("Horizontal lines are blasted to the screen for a 5 second period.\n");
  44.   printf ("\n\nPress any key to continue.\n");
  45.   getch ();
  46.  
  47.   oldmode = wgetmode ();         /* Gets the current mode        */
  48.   vga256 ();                     /* Initializes WGT system       */
  49.   wcls (0);                      /* Clear screen with color 0    */
  50.  
  51.   row = 0;                      /* Start drawing at top row of screen */
  52.   loopctr = 0;
  53.   winittimer ();
  54.   wstarttimer (timerctr, TICKS(100));  /* Set timer to 100th of a second accuracy */
  55.   do {
  56.     wsetcolor (rand () % 256);  /* Pick a random color */
  57.     whline (0, 319, row++);     /* Draw the line */
  58.     if (row > 199)              /* Loop at end of screen */
  59.       row = 0;
  60.   } while (loopctr < 500);       
  61.  
  62.   /* As soon as we reach 500 hundredths of a second (5 secs), end the routine
  63.      and reset the video mode */
  64.   wstoptimer ();
  65.   wdonetimer ();
  66.   wsetmode (oldmode);            /* Restore old video mode       */
  67. }
  68.